<!--
    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="lib/moment/moment.js"></script>
    <script type="text/javascript" src="lib/tablesort/tablesort.min.js"></script>
    <script type="text/javascript" src="lib/tablesort/tablesort.number.js"></script>
    <script type="text/javascript" src="lib/tablesort/tablesort.filesize.js"></script>
    <script src="lib/vex/vex.combined.min.js"></script>
    <script>vex.defaultOptions.className = 'vex-theme-plain'</script>
    <link rel="stylesheet" href="lib/vex/vex.css" />
    <link rel="stylesheet" href="lib/vex/vex-theme-plain.css" />
    <script type="text/javascript" src="mesh.js"></script>
    <link rel="stylesheet" href="https://unpkg.com/purecss@0.6.2/build/pure-min.css"
          integrity="sha384-UQiGfs9ICog+LwheBSRCt1o5cbyKIHbwjWscjemyBMT9YCUMZffs6UqUTd0hObXD" crossorigin="anonymous">
    <style type="text/css">
        #spinner, #viewer {
            display: none;
            height: 100%;
        }
        #spinner {
            text-align: center;
        }
        #spinner::before {
            content: ' ';
            display: inline-block;
            vertical-align: middle;
            height: 100%;
        }
        #spinner img {
            vertical-align: middle;
            display: inline-block;
        }
        #file-content {
            width: calc(100% - 2px);
            height: calc(100% - 20px);
            border: #ccc 1px solid;
        }
        #buttons {
            position: absolute;
            right: 15%;
        }
        html, body {
            height: 100%;
            margin: 0px;
            padding: 0px;
        }
        body {
            width: 100%;
            background: #ccc;
            overflow: hidden;
        }
        #mesh {
            height: calc(100% - 80px);
            width: 70%;
            margin: 20px auto;
            padding: 20px;
            min-width: 500px;
            background: #fff;
            box-shadow: 0px 0px 8px 1px rgba(112,112,112,1);
        }
        #pwd {
            width: calc(100% - 120px);
            margin: 0 10px;
        }
        #nav button {
            width: 90px;
        }
        #table {
            margin-top: 20px;
            height: calc(100% - 50px);
            overflow: scroll;
        }
        table {
            width: 100%;
        }
        #table table td {
            padding: 5px;
        }
        a.file-link, a.file-link:visited {
            color: #04A;
        }
        a.file-link::before {
            content: '';
            background: no-repeat center/20px;
            height: 20px;
            width: 20px;
            margin: 0 5px 0;
            display: inline-block;
            vertical-align: bottom;
        }
        a.file::before {
            background-image: url("img/file.svg");
        }
        a.dir::before {
            background-image: url("img/dir.svg");
        }

        th {
            white-space: nowrap;
        }

        th[role=columnheader]:not(.no-sort) {
            cursor: pointer;
        }

        th[role=columnheader]:not(.no-sort):after {
            content: '';
            display: inline-block;
            width: 20px;
            height: 20px;
            background: url("img/up.svg") no-repeat 0px 5px/16px;
            visibility: hidden;
            opacity: 0;
            user-select: none;
            vertical-align: bottom;
        }

        th[aria-sort=ascending]:not(.no-sort):after {
            content: '';
            background-image: url("img/down.svg")
        }

        th[aria-sort]:not(.no-sort):after {
            visibility: visible;
            opacity: 0.4;
        }

        th[role=columnheader]:not(.no-sort):hover:after {
            visibility: visible;
            opacity: 1;
        }
    </style>
    <title>Mesh Browser</title>
</head>
<body>
    <div id="mesh">
        <div id="nav">
            <form class="pure-form">
                <button id="up" class="pure-button pure-button-primary">Go Up</button>
                <input type="text" id="pwd" class="pure-input pure-input-rounded">
                <!-- <button id="cancel" class="pure-button pure-button-primary">Cancel</button> -->
            </form>
        </div>
        <div id="table">
            <table class="pure-table pure-table-horizontal pure-table-striped">
                <thead>
                    <tr>
                        <th>Name</th>
                        <th data-sort-method="filesize">Size</th>
                        <th data-sort-method="number">Modified</th>
                        <th>Host</th>
                    </tr>
                </thead>
                <tbody id="files"></tbody>
            </table>
            <div id="spinner">
                <img src="img/ring-alt.svg">
            </div>
            <div id="viewer">
                <div id="buttons">
                    <a id="download" class="pure-button">Download file</a>
                    <button id="close-file" class="pure-button">Close</button>
                </div>
                <object id="file-content" type="text/html"></object>
            </div>
        </div>
    </div>
</body>
</html>